import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex) // vue的插件机制
// Vuex.Store 构造器选项
const store = new Vuex.Store({
	// 为了不和页面或组件的data中的造成混淆，state中的变量前面建议加上$符号
	plugins: [
		createPersistedState({
			storage: {
				getItem: key => uni.getStorageSync(key),
				setItem: (key, value) => uni.setStorageSync(key, value),
				removeItem: key => uni.removeStorageSync(key)
			}
		})
	],
	state: {
		// 用户信息
		$token: '',
		$userInfo: null,
		$bingding:false,	
		$school:{
			id:1,
			schoolName:'泉州信息工程学院',
			province:"福建省",
			city:'泉州市',
			area:'丰泽区',
			latitude:'24.942463',
			longitude:'118.583885'
		}
	},
	getters:{
		
	},
	mutations: {
		//同步方法
		setToken(state, token) {
			state.$token = token
		},
		setUserInfo(state, userInfo) {
			state.$userInfo = userInfo;
		},
		setBinding(state,binding){
			state.$bingding=binding;
		},
		changeSchool(state,school){
			state.$school=school
		}
		
	},
	getters:{
		
	},
	actions:{
		
		
		
	},
	modules:{
		
	}
	

})

export default store
